<%-- 
    Document   : addDvdAction
    Created on : Feb 25, 2012, 3:39:50 AM
    Author     : Hiroroi
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@page import="java.sql.*, DBConnection.*, UserPackage.*" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
            String dvdTitle, dvdDirector, synopsis, price;
            boolean result;
            int dvdYear;
            
            dvdTitle = request.getParameter("dvdTitle");
            dvdDirector = request.getParameter("dvdDirector");
            dvdYear = Integer.parseInt(request.getParameter("dvdYear"));
            synopsis = request.getParameter("synopsis");
            price = request.getParameter("price");
            
            /*dvdTitle = dvdTitle.replaceAll("[^a-zA-Z0-9@._]", "");
            dvdDirector = dvdDirector.replaceAll("[^a-zA-Z0-9@._]", "");*/
            System.out.println();
             inputChecker check = new inputChecker();
            if(check.stringCompare(dvdTitle) && check.stringCompare(dvdDirector)){
            Product newDvd = new Product();
            
            newDvd.setDvdTitle(dvdTitle);
            newDvd.setDvdDirector(dvdDirector);
            newDvd.setDvdYear(dvdYear);
            newDvd.setSynopsis(synopsis);
            newDvd.setPrice(price);
            
            result = new ProductManager().addDvd(newDvd);
            System.out.println(dvdTitle);
            System.out.println(synopsis);
            System.out.println(result);
            
            if(result == true)
                response.sendRedirect("addDvd.jsp");
                       }
            else
                response.sendRedirect("prodMgrHomePage.jsp");
          %>
    </body>
</html>
